<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<div>  <!-- <h4 id="name">李玉刚 - 刚好遇见你</h4> -->
		 <br><audio id="audio"  controls autoplay="true"></audio><br/></div><br><br><div><button id="btn-play" >播放</button>  <button id="btn-stop" >暂停</button>  <button id="btn-pre" >上一首</button>  <button id="btn-next" >下一首</button>  </div></div>
		<script>  
		var btn1 = document.getElementById("btn-play");	
				btn1.onclick = function(){		 	 
					if(audio.paused){  audio.play();
													}		}		
				var btn2 = document.getElementById("btn-stop");		
						btn2.onclick = function(){		 	 if(audio.played){                 				
							audio.pause();}		
							}			
							var music = new Array();	
							music = ["李玉刚 - 刚好遇见你","张杰 - 三生三世","朴树 - 平凡之路"];
								var num = 0;	var name = document.getElementById("name"); 	
									var btn3 = document.getElementById("btn-pre");	
								btn3.onclick = function(){			num = (num +2)%3;		 	
								audio.src =  "music/"+music[num]+".mp3";			
								name.innerHTML = music[num];			audio.play();		}		
										var btn4 = document.getElementById("btn-next");	
									btn4.onclick = function(){		 	num = (num +1)%3;		 	
									audio.src =  "music/"+music[num]+".mp3";			
									name.innerHTML = music[num];			audio.play();		}     
									      
									   audio.addEventListener('ended', function () 
									   {                            btn4.onclick();         },
										false);
					</script>
	
	</body>
</html>
